<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
     <!-- <el-form-item label="公司代码" prop="factoryCode">
        <el-input
          v-model="queryParams.factoryCode"
          placeholder="请输入公司代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="factoryName">
        <el-input
          v-model="queryParams.factoryName"
          placeholder="请输入公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="物料编号" prop="itemCode">
        <el-input
          v-model="queryParams.itemCode"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料子编号" prop="itemId">
        <el-input
          v-model="queryParams.itemId"
          placeholder="请输入物料子编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料识别码" prop="itemIdentifyCode">
        <el-input
          v-model="queryParams.itemIdentifyCode"
          placeholder="请输入物料识别码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料单位" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入物料单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="关键部件图号" prop="gjbjItemId">
        <el-input
          v-model="queryParams.gjbjItemId"
          placeholder="请输入关键部件图号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="关键部件名称" prop="gjbjItemName">
        <el-input
          v-model="queryParams.gjbjItemName"
          placeholder="请输入关键部件名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="条码号" prop="tmh">
        <el-input
          v-model="queryParams.tmh"
          placeholder="请输入条码号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料分类编码" prop="classId">
        <el-input
          v-model="queryParams.classId"
          placeholder="请输入物料分类编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料分类名称" prop="className">
        <el-input
          v-model="queryParams.className"
          placeholder="请输入物料分类名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料大类编码" prop="classBigId">
        <el-input
          v-model="queryParams.classBigId"
          placeholder="请输入物料大类编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料大类名称" prop="classBigName">
        <el-input
          v-model="queryParams.classBigName"
          placeholder="请输入物料大类名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商编码" prop="supplyId">
        <el-input
          v-model="queryParams.supplyId"
          placeholder="请输入供应商编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商名称" prop="supplyName">
        <el-input
          v-model="queryParams.supplyName"
          placeholder="请输入供应商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商简称" prop="supplyJc">
        <el-input
          v-model="queryParams.supplyJc"
          placeholder="请输入供应商简称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
    <!--  <el-form-item label="产品类型1-零件" prop="proLx">
        <el-input
          v-model="queryParams.proLx"
          placeholder="请输入产品类型1-零件"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['base:iteminfoPro:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['base:iteminfoPro:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['base:iteminfoPro:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['base:iteminfoPro:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="iteminfoProList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="公司代码" align="center" prop="factoryCode" />
      <el-table-column label="公司名称" align="center" prop="factoryName" />
      <el-table-column label="物料编号" width="220" show-overflow-tooltip align="center" prop="itemCode" />
      <el-table-column label="物料子编号" width="220" show-overflow-tooltip align="center" prop="itemId" />
      <el-table-column label="物料识别码" width="220" show-overflow-tooltip align="center" prop="itemIdentifyCode" />
      <el-table-column label="物料名称" width="220" show-overflow-tooltip align="center" prop="itemName" />
      <el-table-column label="物料单位" align="center" prop="unit" />
      <el-table-column label="规格型号" width="220" show-overflow-tooltip align="center" prop="spec" />
      <el-table-column label="制造类别" width="100" show-overflow-tooltip align="center" prop="zzlb" />
      <el-table-column label="物料定义" width="100" show-overflow-tooltip align="center" prop="wljb" />
      <el-table-column label="关键部件图号" width="220" show-overflow-tooltip align="center" prop="gjbjItemId" />
      <el-table-column label="关键部件名称" width="220" show-overflow-tooltip align="center" prop="gjbjItemName" />
      <el-table-column label="关键部件功率" width="220" show-overflow-tooltip align="center" prop="gjbjGl" />
      <el-table-column label="产品功率" align="center" prop="proGl" />
      <el-table-column label="条码号" width="220" show-overflow-tooltip align="center" prop="tmh" />
      <el-table-column label="物料分类编码" width="120" align="center" prop="classId" />
      <el-table-column label="物料分类名称" width="120" align="center" prop="className" />
      <el-table-column label="物料大类编码" width="120" align="center" prop="classBigId" />
      <el-table-column label="物料大类名称" width="120" align="center" prop="classBigName" />
      <el-table-column label="制造类型" width="120" align="center" prop="zzType" />
      <el-table-column label="物料定义" width="120" align="center" prop="itemDefinition" />
      <el-table-column label="供应商编码" width="120"  align="center" prop="supplyId" />
      <el-table-column label="供应商名称" width="120" align="center" prop="supplyName" />
      <el-table-column label="供应商类别" width="120" align="center" prop="supplyType" />
      <el-table-column label="供应商简称" width="120" align="center" prop="supplyJc" />
      <el-table-column label="存储期" align="center" prop="cunchudate" />
      <el-table-column label="保质期" align="center" prop="productiondate" />
      <el-table-column label="图片地址" align="center" prop="url" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.url" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="尺寸" align="center" prop="size" />
      <el-table-column label="单重" align="center" prop="singleWeight" />
      <el-table-column label="使用状态" align="center" prop="useState" />
      <el-table-column label="颜色" align="center" prop="color" />
      <el-table-column label="花纹" align="center" prop="figure" />
      <el-table-column label="材质" align="center" prop="caizhi" />
      <el-table-column label="包装数量" align="center" prop="baozhuangQty" />
      <el-table-column label="包装方式" align="center" prop="baozhuangType" />
      <el-table-column label="物料状态" align="center" prop="stopFlag" />
      <el-table-column label="成本价" align="center" prop="price" />
      <el-table-column label="计划价" align="center" prop="jhPrice" />
      <el-table-column label="合同价" align="center" prop="htPrice" />
      <el-table-column label="发票价" align="center" prop="fpPrice" />
      <el-table-column label="结算价" align="center" prop="jsPrice" />
      <el-table-column label="生产周期" align="center" prop="proCycle" />
      <el-table-column label="供货周期" align="center" prop="deliveryCycle" />
      <el-table-column label="物流方式" align="center" prop="wlFs" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" width="120" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['base:iteminfoPro:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['base:iteminfoPro:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改零件管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="公司代码" prop="factoryCode">
              <el-input v-model="form.factoryCode" placeholder="请输入公司代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公司名称" prop="factoryName">
              <el-input v-model="form.factoryName" placeholder="请输入公司名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料编号" prop="itemCode">
              <el-input v-model="form.itemCode" placeholder="请输入物料编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料子编号" prop="itemId">
              <el-input v-model="form.itemId" placeholder="请输入物料子编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料识别码" prop="itemIdentifyCode">
              <el-input v-model="form.itemIdentifyCode" placeholder="请输入物料识别码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="itemName">
              <el-input v-model="form.itemName" placeholder="请输入物料名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料单位" prop="unit">
              <el-input v-model="form.unit" placeholder="请输入物料单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="spec">
              <el-input v-model="form.spec" placeholder="请输入规格型号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造类别" prop="zzlb">
              <el-select style="width:100%" v-model="form.zzlb" placeholder="请选择制造类别">
                <el-option
                  v-for="dict in dict.type.zzlb"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料定义" prop="wljb">
              <el-select style="width:100%" v-model="form.wljb" placeholder="请选择物料定义">
                <el-option
                  v-for="dict in dict.type.wljb"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料分类编码" prop="classId">
              <el-input v-model="form.classId" placeholder="请输入物料分类编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料分类名称" prop="className">
              <el-input v-model="form.className" placeholder="请输入物料分类名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料大类编码" prop="classBigId">
              <el-input v-model="form.classBigId" placeholder="请输入物料大类编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料大类名称" prop="classBigName">
              <el-input v-model="form.classBigName" placeholder="请输入物料大类名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商编码" prop="supplyId">
              <el-input v-model="form.supplyId" placeholder="请输入供应商编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商名称" prop="supplyName">
              <el-input v-model="form.supplyName" placeholder="请输入供应商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商简称" prop="supplyJc">
              <el-input v-model="form.supplyJc" placeholder="请输入供应商简称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="存储期" prop="cunchudate">
              <el-input v-model="form.cunchudate" placeholder="请输入存储期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="保质期" prop="productiondate">
              <el-input v-model="form.productiondate" placeholder="请输入保质期" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="图片地址" prop="url">
              <image-upload v-model="form.url"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尺寸" prop="size">
              <el-input v-model="form.size" placeholder="请输入尺寸" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单重" prop="singleWeight">
              <el-input v-model="form.singleWeight" placeholder="请输入单重" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="使用状态" prop="useState">
              <el-input v-model="form.useState" placeholder="请输入使用状态" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="颜色" prop="color">
              <el-input v-model="form.color" placeholder="请输入颜色" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="花纹" prop="figure">
              <el-input v-model="form.figure" placeholder="请输入花纹" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="材质" prop="caizhi">
              <el-input v-model="form.caizhi" placeholder="请输入材质" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装数量" prop="baozhuangQty">
              <el-input v-model="form.baozhuangQty" placeholder="请输入包装数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="成本价" prop="price">
              <el-input v-model="form.price" placeholder="请输入成本价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划价" prop="jhPrice">
              <el-input v-model="form.jhPrice" placeholder="请输入计划价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同价" prop="htPrice">
              <el-input v-model="form.htPrice" placeholder="请输入合同价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发票价" prop="fpPrice">
              <el-input v-model="form.fpPrice" placeholder="请输入发票价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结算价" prop="jsPrice">
              <el-input v-model="form.jsPrice" placeholder="请输入结算价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生产周期" prop="proCycle">
              <el-input v-model="form.proCycle" placeholder="请输入生产周期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货周期" prop="deliveryCycle">
              <el-input v-model="form.deliveryCycle" placeholder="请输入供货周期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料状态" prop="stopFlag">
              <el-input v-model="form.stopFlag" placeholder="请输入物料状态" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="关键部件图号" prop="gjbjItemId">
              <el-input v-model="form.gjbjItemId" placeholder="请输入关键部件图号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="关键部件名称" prop="gjbjItemName">
              <el-input v-model="form.gjbjItemName" placeholder="请输入关键部件名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="关键部件功率" prop="gjbjGl">
              <el-input v-model="form.gjbjGl" placeholder="请输入关键部件功率" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产品功率" prop="proGl">
              <el-input v-model="form.proGl" placeholder="请输入产品功率" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物流方式" prop="wlFs">
              <el-input v-model="form.wlFs" placeholder="请输入物流方式" />
            </el-form-item>
          </el-col>
         <!-- <el-col :span="12">
            <el-form-item label="产品类型1-零件" prop="proLx">
              <el-input v-model="form.proLx" placeholder="请输入产品类型1-零件" />
            </el-form-item>
          </el-col>-->
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listIteminfoPro, getIteminfoPro, delIteminfoPro, addIteminfoPro, updateIteminfoPro } from "@/api/base/iteminfoPro";
import {getToken} from "@/utils/auth";
export default {
  name: "IteminfoProLj",
  dicts: ['zzlb', 'wljb'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 零件管理表格数据
      iteminfoProList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        factoryCode: null,
        factoryName: null,
        itemCode: null,
        itemId: null,
        itemIdentifyCode: null,
        itemName: null,
        unit: null,
        spec: null,
        model: null,
        tmh: null,
        classId: null,
        className: null,
        classBigId: null,
        classBigName: null,
        supplyId: null,
        supplyName: null,
        supplyType: null,
        supplyJc: null,
        gjbjItemId: null,
        gjbjItemName: null,
        proLx: '1'
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`iteminfoPro`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/base/iteminfoPro/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询零件管理列表 */
    getList() {
      this.loading = true;
      listIteminfoPro(this.queryParams).then(response => {
        this.iteminfoProList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryCode: null,
        factoryName: null,
        itemCode: null,
        itemId: null,
        itemIdentifyCode: null,
        itemName: null,
        unit: null,
        spec: null,
        model: null,
        tmh: null,
        classId: null,
        className: null,
        classBigId: null,
        classBigName: null,
        supplyId: null,
        supplyName: null,
        supplyType: null,
        supplyJc: null,
        cunchudate: null,
        productiondate: null,
        url: null,
        size: null,
        singleWeight: null,
        useState: null,
        color: null,
        figure: null,
        caizhi: null,
        baozhuangQty: null,
        baozhuangType: null,
        price: null,
        jhPrice: null,
        htPrice: null,
        fpPrice: null,
        jsPrice: null,
        proCycle: null,
        deliveryCycle: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        stopFlag: null,
        gjbjItemId: null,
        gjbjItemName: null,
        gjbjGl: null,
        proGl: null,
        wlFs: null,
        proLx: "2"
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加零件管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getIteminfoPro(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改零件管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateIteminfoPro(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addIteminfoPro(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delIteminfoPro(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('base/iteminfoPro/export', {
        ...this.queryParams
      }, `零件管理导出_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "零件管理导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('base/iteminfoPro/importTemplate', {
      }, `零件管理模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
